package com.opeartion.controller;

import com.opeartion.pojo.CheckStatus;
import com.opeartion.pojo.Store;
import com.opeartion.service.impl.StoreServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;


@RestController
@RequestMapping("/store")
public class StoreController {

    @Autowired
    private StoreServiceImpl storeService;

    @GetMapping("/list")
    public List<Store> getAll() {
        return storeService.getAllStore();
    }

    //搜寻店铺
    @GetMapping("/findStore")
    public List<Store> findStore(String storeld) {

        return storeService.findStore(storeld);
    }

    //搜寻行业
    @GetMapping("/findCategotry")
    public List<Store> findCategotry(String name) {
        return storeService.findCategotry(name);
    }

    //改变店铺状态
    @PostMapping("/updateStoreId")
    public Boolean UpdateStoreId(Integer status,Integer id){
         try {
             storeService.UpdateStoreId(status,id);
             System.out.println("success");
             return true;
         }catch (Exception e){
             return false;
         }
    }
    @GetMapping("/checkStatus")
    public List<Store> checkStatus() {
        return storeService.checkStatus();
    }

    @PostMapping("/findStatus")
    public List<Store> findStatus(@RequestBody CheckStatus checkStatus) {
        return storeService.findStatus(checkStatus);
    }

    @PostMapping("/UpdateStatus")
    public void UpdateStatus(int status,String describe, int storeld) {
            storeService.UpdateStatus(status,describe,storeld);
    }


}
